<?php

namespace App\Http\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    protected $table = 'users';

    protected $fillable = [
        'name', 'password', 'phone'
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
     * 点劵日志表
     */
    public function usersVoucherLog()
    {
        return $this->hasMany('App\Http\Models\VoucherLog', 'user_id', 'id');
    }

    /**
     * 对应用户授权表
     */
    public function userAuth()
    {
        return $this->hasOne('App\Http\Models\UserAuth', 'user_id', 'id');
    }

    public function UserSubmitAudit()
    {
        return $this->hasOne('App\Http\Models\UserSubmitAudit', 'uid', 'id');
    }

    public function getUserList($page, $per_page, $seache = [])
    {
        /*if($seache){
            $data=
        }else{
            $data =
        }*/
        return $data = [];

    }

    public function UserKillStatus()
    {
        return $this->hasOne('App\Http\Models\UserKillStatus', 'user_id', 'id');
    }

    public function UsersCapital()
    {
        return $this->hasOne('App\Http\Models\UserCapital', 'user_id', 'id');
    }

    public static function getUserName($userId)
    {
        $userinfo = User::find($userId);
        $u_name = $userinfo ? $userinfo->name : '';
        return $u_name;
    }

}